# Melina Demertzi

# This file extracts the necessary mindmap
# information, given the mindmap presented 
# in XML format

import sys
from xml.etree import ElementTree

class Mindmap:
	# extract the necessary information given the 
	# xmlfile
	def __init__(self, xmlfile):
		self.labels = []
	     	self.edges = []
	     	self.nodes = []
	     	tree = ElementTree.parse(xmlfile)
		
		# get all the mindmap nodes
		iter = tree.getiterator("node")
		for element in iter:
			for child in element:
				if child.tag != "color":
					self.nodes.append(child.text)

		# get all the mindmap edges
		iter = tree.getiterator("edge")
		for element in iter:
			edge_data = []
			for child in element:
				if child.tag != "color":
					edge_data.append(child.text)
			self.edges.append(edge_data)

		#get distinct version ofedge labels
		#not current implementation
		for edge in self.edges:
			if edge[0] not in self.labels:
				self.labels.append(edge[0])

	#create get/set methods for interface
	def get_mindmap_nodes(self):
		return self.nodes

	def get_mindmap_edges(self):
		return self.edges

	def get_mindmap_labels(self):
		return self.labels
			


